package com.postsuperman.proxypool.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
import com.postsuperman.proxypool.api.ToolApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * 定时同步代理IP池
 *
 * @author ： Lwl postserupman
 * @Description TODO
 * @Date 2019/2/27 12:06
 * @Version 1.0
 */
@Component
@ElasticSimpleJob(cron = "0 0 1 ? * L")
public class ProxySyncJob implements SimpleJob {

    @Autowired
    private ToolApi toolApi;

    @Value("${job.sync.enabled}")
    private Boolean enabled;

    @Override
    public void execute(ShardingContext shardingContext) {
        if(enabled){
            toolApi.proxySync();
        }
    }
}
